package pl.edu.agh.administracja.networkconfig.model;

/**
 *
 * @author piotrek
 */
public class NetworkInterfaceConfig {
    
    protected String name;
    protected IpV4Address ipAddress;
    protected IpV4Address mask;
    protected IpV4Address defaultGateway;
    protected String hardwareAddress = "";
    protected transient String sent;
    protected transient String received;
    protected boolean ipViaDHCP;
    protected transient boolean on = false;
    
    public NetworkInterfaceConfig(){
        
    }
    
    public String getHardwareAddress() {
        return hardwareAddress;
    }

    public void setHardwareAddress(String hardwareAddress) {
        this.hardwareAddress = hardwareAddress;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public IpV4Address getDefaultGateway() {
        return defaultGateway;
    }

    public void setDefaultGateway(IpV4Address defaultGateway) {
        this.defaultGateway = defaultGateway;
    }

    public IpV4Address getIpAddress() {
        return ipAddress;
    }

    public void setIpAddress(IpV4Address ipAddress) {
        this.ipAddress = ipAddress;
    }

    public IpV4Address getMask() {
        return mask;
    }

    public void setMask(IpV4Address mask) {
        this.mask = mask;
    }

    public boolean isIpViaDHCP() {
        return ipViaDHCP;
    }

    public void setIpViaDHCP(boolean ipViaDHCP) {
        this.ipViaDHCP = ipViaDHCP;
        setIpAddress(null);
        setMask(null);
        setDefaultGateway(null);
    }

    public String getReceived() {
        return received;
    }

    public void setReceived(String received) {
        this.received = received;
    }

    public String getSent() {
        return sent;
    }

    public void setSent(String sent) {
        this.sent = sent;
    }

    
    public boolean isOn() {
        return on;
    }
    
    public void setOn(boolean on) {
        this.on = on;
    }
    
    @Override
    public String toString() {
        return getName();
    }
    
    @Override
    public boolean equals(Object o) {
        if(!(o instanceof NetworkInterfaceConfig))
            return false;
        
        NetworkInterfaceConfig toCmp = (NetworkInterfaceConfig) o;
        
        if(toCmp.getName() == null)
            return false;
        
        return name.equals(toCmp.getName());
    }
}
